package com.hmall.order.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.OrderDTO;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private IOrderService orderService;

    @GetMapping("/{id}")
    public Order queryOrderById(@PathVariable("id") Long orderId) {
        return orderService.getById(orderId);
    }

    /**
     * 下单，生成订单
     *
     * @param orderDTO 生成订单，需要的数据DTO
     * @return 生成的订单Id
     */
    @PostMapping
    public Long createOrder(@RequestBody OrderDTO orderDTO) {
        return orderService.createOrder(orderDTO);
    }
}